let RecordStatus = require("suit/audio/record_status").RecordStatus;
let msgType = require("../msgtype");

Component({
  properties: {
    username: {
      type: Object,
      value: {}
    },
    chufang: {
      type: Object,
      value: {}
    },
    chatType: {
      type: String,
      value: msgType.chatType.SINGLE_CHAT,
    },
    list: {
      type: String,
      value: {}
    },
    orders: {
      type: String,
      value: ''
    },
    useropenid: {
      type: String,
      value: ''
    },
    z_name: {
      type: String,
      value: ''
    }
  },
  pageLifetimes: {
    show: function() {
      // 页面被展示
      console.log(this.properties.z_name)
      console.log(this.properties.list)
      console.log(this.properties.useropenid)
      console.log(this.properties.username.myName)
      console.log(this.properties.orders)
      var list = JSON.parse(this.properties.list)
      var zid = list.zid
      var j_id = list.j_id
      this.setData({
        useropenid: this.properties.useropenid,
        zid: zid,
        j_id: j_id,
        myName: this.properties.username.myName,
        your: this.properties.username.your
      })

    },
  },
  data: {
    recordStatus: RecordStatus.HIDE,
    RecordStatus,
    __comps__: {
      main: null,
      emoji: null,
      image: null,
      location: null,
      //video: null,
    },
  },
  methods: {
    remove(){
      this.setData({
        chufang:false
      })
    },
    navBack:function(e){
      var url=e.currentTarget.dataset.url
      wx.navigateTo({
        url: url,
      })
    },
    // 事件有长度限制：仅限 26 字符
    toggleRecordModal() {
      this.triggerEvent(
        "tapSendAudio",
        null, {
          bubbles: true,
          composed: true
        }
      );
    },
    sendMessage(e) {
      var that = this
      var useropenid = that.properties.useropenid
      var zid = that.data.zid
      var j_id = that.data.j_id
      var myName = that.data.myName
      var your = that.data.your
      wx.navigateTo({
        url: '/hyb_yl/addPrescription/addPrescription?useropenid=' + useropenid + '&j_id=' + j_id + '&zid=' + zid + '&myName=' + myName + '&your=' + your,
      })
    },
    // sendVideo(){
    // 	this.data.__comps__.video.sendVideo();
    // },

    openCamera() {
      this.data.__comps__.image.openCamera();
    },

    openEmoji() {
      this.data.__comps__.emoji.openEmoji();
    },

    // cancelEmoji() {
    //   this.data.__comps__.emoji.cancelEmoji();
    // },

    sendImage() {
      this.data.__comps__.image.sendImage();
    },

    sendLocation() {
      this.data.__comps__.location.sendLocation();
    },

    emojiAction(evt) {
      this.data.__comps__.main.emojiAction(evt.detail.msg);
    },
  },

  // lifetimes
  created() {},
  attached() {},
  moved() {},
  detached() {},
  ready() {
    var sate = wx.getStorageSync('sate')
    this.setData({
      isIPX: getApp().globalData.isIPX,
      sate: sate
    })
    let comps = this.data.__comps__;
    comps.main = this.selectComponent("#chat-suit-main");
    comps.emoji = this.selectComponent("#chat-suit-emoji");
    comps.image = this.selectComponent("#chat-suit-image");
    // comps.location = this.selectComponent("#chat-suit-location");
    //comps.video = this.selectComponent("#chat-suit-video");
  },
});